<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>for</title>
    <script>
        // 1-100之和
        var num = 0;
        for (var i = 1; i <= 100; i++) {
            num += i;
        }
        console.log(num);
        // 1-100之间偶数之和
        var result = 0;
        var result1 = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                result += i;
            } else {

                result1 += i;
            }
        }
        console.log(result);
        console.log(result1);
        // 1-100之间所有数的平均值
        var result2 = 0;

        for (var i = 1; i <= 100; i++) {
            result2 += i;
        }

        console.log(result2 / 100);
        // 1-100之间能被3整除数之和
        var result3 = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 3 == 0) {
                result3 += i;
            }
        }
        console.log(result3);
    </script>
</head>

<body>

</body>

</html>